package app

import (
	"github.com/gin-gonic/gin"
	"web-tools-go/controller"
	"web-tools-go/define"
)

func Route() *gin.Engine {
	r := gin.Default()
	r.LoadHTMLGlob("templates/*")
	r.Static("/static", "./static")
	r.Static("/assets", define.StaticPath)

	r.GET("/", controller.IndexPage)

	r.GET("/rand", controller.RandPage)
	r.POST("/rand", controller.GenerateRand)

	r.GET("/qrcode", controller.QrcodePage)
	r.GET("/qrcode/generate", controller.GenerateQrcode)

	r.GET("/ip", controller.IpPage)

	r.GET("/time-stamp", controller.TimeStampPage)
	r.POST("/time-stamp-to-time", controller.TimeStampToTime)
	r.POST("/time-to-time-stamp", controller.TimeToTimeStamp)

	r.GET("/json", controller.JsonPage)
	r.POST("/json", controller.JsonFormat)

	r.GET("/postman", controller.PostmanPage)
	r.POST("/postman", controller.PostmanSendData)

	r.POST("/file-upload", controller.FileUpload)

	r.GET("/base64", controller.Base64Page)
	r.POST("/base64/image-to-base64", controller.ImageToBase64)

	// BarCode
	r.GET("/barcode", controller.BarcodePage)
	r.GET("/barcode/generate", controller.GenerateBarcode)

	r.GET("/markdown", controller.MarkdownPage)

	r.GET("/online-spreadsheet", controller.OnlineSpreadsheet)

	// 获取静态资源文件列表
	r.GET("/file-list", controller.FileListPage)
	r.POST("/file-list", controller.FileList)

	r.GET("/md5", controller.Md5Page)
	r.POST("/md5", controller.Md5Transform)

	r.GET("/totp", controller.TotpPage)
	r.POST("/totp", controller.TotpGenerate)

	return r
}
